<script setup>
import {ref, reactive} from 'vue'
import sider from './ReviewSider.vue'
import heade from './ReviewHeader.vue'
// 操作日志数据
const operationLogs = reactive([
  {
    id: 1,
    operator: '管理员',
    action: '审批通过',
    target: '张三的差旅申请',
    time: '2025-11-09 14:30:00',
    remark: '金额合理，行程安排妥当'
  },
  {
    id: 2,
    operator: '管理员',
    action: '审批驳回',
    target: '赵六的差旅申请',
    time: '2025-11-09 10:15:00',
    remark: '缺少相关证明材料'
  },
  {
    id: 3,
    operator: '管理员',
    action: '审批通过',
    target: '王五的差旅申请',
    time: '2025-11-08 16:45:00',
    remark: '符合公司差旅标准'
  }
])
// 当前选中的日志
const selectedLog = ref(null)
const isEditingLog = ref(false)
const editingLog = reactive({})
// 查看日志详情
const viewLogDetail = (log) => {
  selectedLog.value = log
  Object.assign(editingLog, log)
}
// 编辑日志
const editLog = () => {
  isEditingLog.value = true
}
// 保存日志修改
const saveLog = () => {
  const index = operationLogs.findIndex(l => l.id === editingLog.id)
  if (index !== -1) {
    Object.assign(operationLogs[index], editingLog)
  }
  isEditingLog.value = false
}
// 取消编辑
const cancelEdit = () => {
  isEditingLog.value = false
  Object.assign(editingLog, selectedLog.value)
}
</script>
<template>
  <div class="admin-layout">
    <!-- 顶栏 -->
    <div class=topbar>
      <heade/>
    </div>
    <!-- 侧边栏 -->
    <div class=sidebar>
      <div class=sidebar-menu>
        <sider/>
      </div>
    </div>
    <!-- 主内容区容器 -->
    <div class="content-wrapper">
      <div class="main-content">
        <div class="content-section">
           <div class = "section-header">
             <h3>数据分析</h3>
           </div>
        </div>
      </div>
      <!-- 主内容区 -->
    </div>
  </div>
</template>
<style scoped>
/* --- 总体布局 --- */
.admin-layout {
  display: flex;
  height: 100vh;
  background: #f5f5f5;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.content-wrapper {
  margin-top: 50px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* --- 侧边栏样式 --- */
.sidebar {
  width: 260px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  box-sizing: border-box;
  flex-direction: column;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
  padding: 30px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
  margin: 0 0 5px 0;
  font-size: 20px;
  font-weight: 600;
}

.sidebar-header p {
  margin: 0;
  font-size: 14px;
  opacity: 0.8;
}

.sidebar-menu {
  flex: 1;
  padding: 20px 0;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 15px 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.menu-item.active {
  background: rgba(255, 255, 255, 0.2);
  border-left-color: white;
}

.menu-icon {
  font-size: 20px;
  margin-right: 15px;
  width: 25px;
  text-align: center;
}

.menu-text {
  font-size: 15px;
  font-weight: 500;
}

/* --- 顶栏样式 --- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
  padding: 0 30px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  z-index: 10;
}

.breadcrumb {
  font-size: 18px;
  font-weight: 500;
  color: #333;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.username {
  font-size: 15px;
  color: #555;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.user-avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.avatar-text {
  color: white;
  font-weight: 600;
  font-size: 16px;
}

/* --- 主内容区样式 --- */
.main-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.content-section {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 25px 30px;
  border-bottom: 1px solid #e8e8e8;
}

.section-header h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: #333;
}

/* --- 工作列表样式 --- */
.filter-buttons {
  display: flex;
  gap: 10px;
}

.filter-btn {
  padding: 8px 16px;
  border: 1px solid #d9d9d9;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
}

.filter-btn:hover {
  border-color: #667eea;
  color: #667eea;
}

.filter-btn.active {
  background: #667eea;
  border-color: #667eea;
  color: white;
}

.work-list {
  padding: 20px 30px;
  overflow-y: auto;
}

.work-item {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 15px;
  transition: all 0.3s ease;
  border: 1px solid #e8e8e8;
}

.work-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.work-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.work-item-header h4 {
  margin: 0;
  font-size: 16px;
  color: #333;
}

.status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge.pending {
  background: #fff3cd;
  color: #856404;
}

.status-badge.approved {
  background: #d4edda;
  color: #155724;
}

.status-badge.rejected {
  background: #f8d7da;
  color: #721c24;
}

.work-item-info {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 15px;
}

.work-item-info p {
  margin: 0;
  font-size: 14px;
  color: #666;
}

.priority {
  font-weight: 500;
}

.priority.high {
  color: #e74c3c;
}

.priority.medium {
  color: #f39c12;
}

.priority.low {
  color: #27ae60;
}

.work-item-actions {
  display: flex;
  gap: 10px;
}

.btn-approve, .btn-reject {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.btn-approve {
  background: #28a745;
  color: white;
}

.btn-approve:hover {
  background: #218838;
}

.btn-reject {
  background: #dc3545;
  color: white;
}

.btn-reject:hover {
  background: #c82333;
}

/* --- 操作日志样式 --- */
.logs-container {
  display: flex;
  height: 100%;
}

.logs-list {
  width: 40%;
  border-right: 1px solid #e8e8e8;
  overflow-y: auto;
}

.log-item {
  padding: 20px 30px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: all 0.3s ease;
}

.log-item:hover {
  background: #f8f9fa;
}

.log-item.active {
  background: #e8f4fd;
  border-left: 3px solid #1890ff;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.log-action {
  font-weight: 500;
  color: #1890ff;
}

.log-time {
  font-size: 12px;
  color: #999;
}

.log-target {
  margin: 0;
  font-size: 14px;
  color: #666;
}

.log-detail {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e8e8e8;
}

.detail-header h4 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

.btn-edit {
  padding: 8px 16px;
  background: #1890ff;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.btn-save {
  padding: 8px 16px;
  background: #52c41a;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  margin-right: 10px;
}

.btn-cancel {
  padding: 8px 16px;
  background: #d9d9d9;
  color: #666;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.detail-content {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.detail-row {
  display: flex;
  align-items: flex-start;
}

.detail-row label {
  width: 100px;
  font-weight: 500;
  color: #333;
  margin-right: 15px;
}

.detail-row input,
.detail-row textarea {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 14px;
}

.detail-row textarea {
  min-height: 80px;
  resize: vertical;
}

/* --- 私信样式 --- */
.messages-container {
  display: flex;
  height: 100%;
}

.messages-list {
  width: 35%;
  border-right: 1px solid #e8e8e8;
  overflow-y: auto;
}

.message-item {
  padding: 20px 30px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.message-item:hover {
  background: #f8f9fa;
}

.message-item.active {
  background: #e8f4fd;
  border-left: 3px solid #1890ff;
}

.message-item.unread {
  background: #f0f9ff;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.message-sender {
  font-weight: 500;
  color: #333;
}

.message-time {
  font-size: 12px;
  color: #999;
}

.message-preview {
  margin: 0;
  font-size: 14px;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unread-dot {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 8px;
  height: 8px;
  background: #ff4d4f;
  border-radius: 50%;
}

.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 20px 30px;
  border-bottom: 1px solid #e8e8e8;
}

.chat-header h4 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

.chat-messages {
  flex: 1;
  padding: 20px 30px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 70%;
}

.chat-message.sent {
  align-self: flex-end;
}

.chat-message.received {
  align-self: flex-start;
}

.message-content {
  padding: 10px 15px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
}

.chat-message.sent .message-content {
  background: #1890ff;
  color: white;
}

.chat-message.received .message-content {
  background: #f0f0f0;
  color: #333;
}

.chat-message .message-time {
  font-size: 12px;
  color: #999;
  margin-top: 5px;
  align-self: flex-end;
}

.chat-message.received .message-time {
  align-self: flex-start;
}

.chat-input {
  padding: 20px 30px;
  border-top: 1px solid #e8e8e8;
  display: flex;
  gap: 10px;
}

.chat-input input {
  flex: 1;
  padding: 10px 15px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 14px;
}

.chat-input button {
  padding: 10px 25px;
  background: #1890ff;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.chat-input button:hover {
  background: #40a9ff;
}

/* --- 个人中心模态框样式 --- */
.profile-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.profile-content {
  background: #fff;
  padding: 0;
  border-radius: 12px;
  width: 400px;
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
  animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 30px;
  border-bottom: 1px solid #e8e8e8;
}

.profile-header h3 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: #aaa;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
}

.close-btn:hover {
  color: #333;
}

.profile-body {
  padding: 30px;
  text-align: center;
}

.profile-avatar-large {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.profile-avatar-large .avatar-text {
  color: white;
  font-weight: 600;
  font-size: 36px;
}

.profile-info h4 {
  margin: 0 0 10px 0;
  font-size: 20px;
  color: #333;
}

.profile-info p {
  margin: 5px 0;
  color: #666;
  font-size: 14px;
}

.profile-actions {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-btn {
  padding: 12px 20px;
  border: 1px solid #d9d9d9;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.3s ease;
}

.profile-btn:hover {
  background-color: #f5f5f5;
  border-color: #667eea;
  color: #667eea;
}

.profile-btn.logout {
  color: #e74c3c;
  border-color: #f8d7da;
}

.profile-btn.logout:hover {
  background-color: #f8d7da;
  border-color: #e74c3c;
}
</style>
